﻿@code {
    [Parameter] public RenderFragment ChildContent { get; set; } = default!;

    [Parameter] public bool AutoReload { get; set; } = true;
    [Parameter] public bool ShowLogs { get; set; } = false;
    [Parameter] public bool ShowAssets { get; set; } = false;
    [Parameter] public string AppContainer { get; set; } = "#app";
    [Parameter] public bool HideApp { get; set; } = false;
    [Parameter] public bool AutoHide { get; set; } = false;
    [Parameter] public string? Handler { get; set; }
}

<div id="bit-bswup">
    @if (ChildContent is not null) 
    {
        @ChildContent
    }
    else 
    {
        <div class="bit-bswup-container">
            <p class="bit-bswup-title">New version is available</p>
            <p class="bit-bswup-description">Downloading updates, please wait...</p>
            <div class="bit-bswup-progress">
                <div id="bit-bswup-progress-bar" style="width: 0%"></div>
            </div>
            <p id="bit-bswup-percent">0 %</p>
            <ul id="bit-bswup-assets" style="display: @(ShowAssets ? "block" : "none");"></ul>
        </div>
        <button id="bit-bswup-reload">Update ready to install!</button>
    }
    <img style="display: none" src=""
         onerror="BitBswupProgress.start(@(AutoReload ? "true" : "false"), @(ShowLogs ? "true" : "false"), @(ShowAssets ? "true" : "false"), '@(AppContainer)', @(HideApp ? "true" : "false"), @(AutoHide ? "true" : "false"), '@(Handler)')">
</div>
